<html>
<head><meta charset="utf-8"><title>Trait selection code · t-compiler/help · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/index.html">t-compiler/help</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Trait.20selection.20code.html">Trait selection code</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="218211494"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Trait%20selection%20code/near/218211494" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Olivier FAURE <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Trait.20selection.20code.html#218211494">(Nov 29 2020 at 12:50)</a>:</h4>
<p>I'm looking at the (vanilla) trait solving code, and trying to grok the general structure. One thing puzzles me: there are two <code>select</code> functions:</p>
<ul>
<li>one in <a href="https://github.com/rust-lang/rust/blob/c4fe25d8613a32dcd71e5258c22ff5685f12d4c3/compiler/rustc_trait_selection/src/traits/select/mod.rs#L311-L314"><code>compiler/rustc_trait_selection/src/traits/select/mod.rs</code></a></li>
<li>one in <a href="https://github.com/rust-lang/rust/blob/c4fe25d8613a32dcd71e5258c22ff5685f12d4c3/compiler/rustc_trait_selection/src/traits/fulfill.rs#L119-L122"><code>compiler/rustc_trait_selection/src/traits/fulfill.rs</code></a></li>
</ul>
<p>I'm inclined to think the first one calls the second, but at first glance it doesn't seem to be the case. What's the deal there?</p>



<a name="218211635"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Trait%20selection%20code/near/218211635" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Olivier FAURE <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Trait.20selection.20code.html#218211635">(Nov 29 2020 at 12:54)</a>:</h4>
<p>Wait, never mind, I found it. The dependency goes the other way.</p>



<a name="218211709"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Trait%20selection%20code/near/218211709" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Olivier FAURE <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Trait.20selection.20code.html#218211709">(Nov 29 2020 at 12:57)</a>:</h4>
<p>It's:</p>
<ul>
<li><code>FulfillmentContext::select</code> (in traits/fulfill.rs)</li>
<li><code>FulfillProcessor::process_obligation</code></li>
<li><code>FulfillProcessor::progress_changed_obligations</code></li>
<li><code>FulfillProcessor::process_trait_obligation</code></li>
<li><code>SelectionContext::select</code> (in traits/select/mod.rs)</li>
</ul>



<a name="218213289"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Trait%20selection%20code/near/218213289" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Trait.20selection.20code.html#218213289">(Nov 29 2020 at 13:39)</a>:</h4>
<p>if it helps, I have a lot of muddling about the trait system in <a href="#narrow/stream/182449-t-compiler.2Fhelp/topic/How.20do.20I.20normalize.20projection.20types.20to.20a.20single.20type.3F">https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/How.20do.20I.20normalize.20projection.20types.20to.20a.20single.20type.3F</a></p>



<a name="218213296"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Trait%20selection%20code/near/218213296" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Trait.20selection.20code.html#218213296">(Nov 29 2020 at 13:39)</a>:</h4>
<p>didn't make any <em>progress</em>, but my findings may be helpful</p>



<a name="218213856"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Trait%20selection%20code/near/218213856" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Olivier FAURE <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Trait.20selection.20code.html#218213856">(Nov 29 2020 at 13:54)</a>:</h4>
<p>It doesn't really help me. Sounds like you're working on a very specific use case, whereas right now I'm just trying to understand the trait system. =/</p>



<a name="218213877"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Trait%20selection%20code/near/218213877" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Trait.20selection.20code.html#218213877">(Nov 29 2020 at 13:55)</a>:</h4>
<p>there's some info in <a href="https://rustc-dev-guide.rust-lang.org/traits/resolution.html">https://rustc-dev-guide.rust-lang.org/traits/resolution.html</a> too</p>



<a name="218215348"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Trait%20selection%20code/near/218215348" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Olivier FAURE <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Trait.20selection.20code.html#218215348">(Nov 29 2020 at 14:37)</a>:</h4>
<p>Yeah. It's a little helpful, but not that much.</p>



<a name="218215406"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Trait%20selection%20code/near/218215406" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Olivier FAURE <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Trait.20selection.20code.html#218215406">(Nov 29 2020 at 14:38)</a>:</h4>
<p>Like, I'm pretty sure the section on traits is the one with the most <strong>TODOs</strong> in the entire dev book.</p>



<a name="218215610"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Trait%20selection%20code/near/218215610" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Olivier FAURE <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Trait.20selection.20code.html#218215610">(Nov 29 2020 at 14:44)</a>:</h4>
<p>Whatever. I think I'm just going to get back to poking at the code and write down questions as I go</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>